<!--
 * @Author: wangshiyang
 * @Date: 2023-06-15 16:45:29
 * @LastEditors: wangshiyang
 * @LastEditTime: 2023-06-15 16:46:34
 * @Description: 请填写简介
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css" rel="stylesheet">
    <script src="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js"></script>
    <script src='https://unpkg.com/@antv/l7'></script>
    <style>
        html,
        body {
            overflow: hidden;
            margin: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <script>
        /* 3、设置token */
        mapboxgl.accessToken = 'pk.eyJ1IjoiY2hlbmdiZW5jaGFvIiwiYSI6ImNsODU3aGRiODA0Y2UzcHBzZmFlcmdqZ2sifQ.8k59W_pB_Riwe6o-MneRlA'
        const scene = new L7.Scene({
            id: 'map',
            map: new L7.Mapbox({
                style: 'mapbox://styles/mapbox/satellite-streets-v11',
                zoom: 1,
                center: [6.6301, 45.35625],
                projection: 'globe'
            })
        });
        const map = scene.map;
        map.on("style.load", () => {
            map.setFog({
            });
        })
        let isUserInterface = false;
        /* map.easeTo({center,duration:1000,easing:n=>n}) */
        function rorateMap() {
            /* zoom<5自动旋转,同时用户没有进行操作,才会执行旋转 */
            const zoom = map.getZoom();
            if (zoom < 5 && !isUserInterface) {
                let center = map.getCenter();
                center.lng += 10;
                map.easeTo({ center, duration: 1000, easing: n => n });
            }

        }
        /* 动画执行完毕之后,触发一个moveend */
        map.on("moveend", () => {
            rorateMap();
        })

        map.on("click", () => {
            isUserInterface = !isUserInterface;
            console.log(isUserInterface)
            if (isUserInterface) {
                map.stop();
            } else {
                rorateMap();
            }
        })
        rorateMap();
    </script>
</body>

</html>